# head_neck mesh generation test

#!/usr/bin/env python

from scipy import *
from enthought.mayavi import mlab
import sys
sys.path.append( '../' )

from field import template_fields
from field import geometric_field


# head neck parameters
h_r = 20.0
n_l = 30.0
n_r = None

eval_density = 20

# make hemi and parameters
(head_neck, xparam, yparam, zparam, cp) = template_fields.head_neck( h_r, n_l, n_r, )

# evaluate
x = head_neck.evaluate_field_in_mesh( eval_density, xparam )
x = array(x).flatten()

y = head_neck.evaluate_field_in_mesh( eval_density, yparam )
y = array(y).flatten()

z = head_neck.evaluate_field_in_mesh( eval_density, zparam )
z = array(z).flatten()

p = mlab.points3d( x,y,z, mode = 'point', scale_factor = 0.5)
n = mlab.points3d( xparam, yparam, zparam, mode = 'sphere', scale_factor = 1.0, color = (1,0,0) )
# label ensemble points
labels = range( len(xparam) )
for i in range( len(labels ) ):
	mlab.text( xparam[i][0], yparam[i][0], str(labels[i]), z = zparam[i][0], line_width = 0.01, width = 0.01 )
mlab.show()
